package ml;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import corpus.SentPolarityCorpus;

import ml.features.FeatureExtractor;

import forum.ForumPost;
import parser.ParserPipeline;

public abstract class DataModel {

	protected String name;
	protected ParserPipeline pp;
	protected List<String> labelTranslations;
	protected List<FeatureExtractor> features;
	protected List<FeatureVector> data;
	protected int nbrFeatures;
	protected MLGlue glue;

	public DataModel(String name, ParserPipeline pp, String[] labels) {
		this.name = name;
		this.pp = pp;
		features = new ArrayList<FeatureExtractor>();
		data = new ArrayList<FeatureVector>();
		labelTranslations = Arrays.asList(labels);
	}

	public abstract void classify(ForumPost post) throws Exception;
	public abstract void extractFeatures(SentPolarityCorpus spc);

	public void setMLGlue(MLGlue glue) {
		this.glue = glue;
	}
	
	protected int labelIndex(String label) {
		return labelTranslations.indexOf(label);
	}
	
	public void addFeatureExtractor(FeatureExtractor fe) {
		features.add(fe);
		nbrFeatures += fe.nbrColumns();
	}

	public String getName() {
		return name;
	}
	
	public List<FeatureVector> getFeatureVectors() {
		return data;
	}

	public int getNbrFeatures() {
		return nbrFeatures;
	}
}
